// src/productSpu.js
import request from '@/utils/request';

/**
 * 分页查询 SPU
 * @param {Object} params {pageNum, pageSize, name?, status?}
 */
export function pageSpu(params) {
    return request.get('/admin/spu/page', { params });
}

// 获取SPU详情
export function getSpuDetail(id) {
    return request.get(`/admin/spu/${id}`);
}

// 新增SPU
export function addSpu(data) {
    return request.post('/admin/spu', data);
}

// 更新SPU
export function updateSpu(data) {
    return request.put('/admin/spu', data);
}

// 删除SPU
export function deleteSpu(ids) {
    return request.delete('/admin/spu', { params: { ids } });
}

// 导出SPU列表
export function exportSpu() {
    return request.get('/admin/spu/export', { responseType: 'blob' });
}

// 下载SPU导入模板
export function downloadSpuTemplate() {
    return request.get('/admin/spu/template', { responseType: 'blob' });
}

// 导入SPU
export function importSpu(file) {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/admin/spu/import', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}


